<?php
define ('HOSTNAME', 'http://carocoops.org/');


$path = ($_POST['url']) ? $_POST['url'] : $_GET['url'];
$postvars = '';
while ($element = current($_GET)) {
  $postvars .= key($_GET).'='.$element.'&';
  next($_GET);
}
$decodedURI = rawurldecode( $path );
#echo( $path );
#echo('</br>');
if( strstr( $decodedURI, HOSTNAME ) )
{
  #echo( $decodedURI );
  #echo('</br>');
  $session = curl_init($decodedURI);
  #if ($_POST['PLATFORM']) {
  #  $postvars = '';
  #  while ($element = current($_POST)) {
  #    $postvars .= key($_POST).'='.$element.'&';
  #    next($_POST);
  #  }
    #echo( $postvars );
    #echo('</br>');
  if( strlen( $postvars ) )
  {
    curl_setopt ($session, CURLOPT_POST, true);
    curl_setopt ($session, CURLOPT_POSTFIELDS, $postvars);
  }

  curl_setopt($session, CURLOPT_HEADER, false);
  curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($session, CURLOPT_FOLLOWLOCATION, true);
  

  $xml = curl_exec($session);

  header("Content-Type: text/xml");

  echo $xml;
  curl_close($session);
}
?>